package com.linkage.educloud.ah.view;

import android.graphics.Color;

import com.linkage.educloud.ah.mvp.IBasicView;
import com.trello.rxlifecycle2.LifecycleTransformer;
import com.trello.rxlifecycle2.components.support.RxFragment;
import com.zyao89.view.zloading.ZLoadingDialog;
import com.zyao89.view.zloading.Z_TYPE;

/**
 * <desc>
 * Created by The Moss on 2018/8/21.
 */

public abstract class AbstractFragment extends RxFragment implements IBasicView {
    protected String TAG = this.getClass().getSimpleName();
    ZLoadingDialog dialog;

    @Override
    public LifecycleTransformer bindLifecycle() {
        return this.bindToLifecycle();
    }
    protected abstract boolean onBackPressed();

    protected void showZloading(){
        if (dialog == null) {
            dialog = new ZLoadingDialog(getActivity());
        }
        dialog.setLoadingBuilder(Z_TYPE.DOUBLE_CIRCLE)//设置类型
                .setLoadingColor(Color.RED)//颜色
                .setHintText("Loading...")
                .setHintTextSize(-1) // 设置字体大小 dp
                .setHintTextColor(Color.GRAY)  // 设置字体颜色
                .setDurationTime(0.5) // 设置动画时间百分比 - 0.5倍
                .setDialogBackgroundColor(Color.parseColor("#CC111111")) // 设置背景色，默认白色
                .show();
    }
    protected void hideZloading(){
        if (dialog != null) {
            dialog.dismiss();
        }
    }
}
